import '../model/result_model.dart';
import '../model/test_level_model.dart';
import '../utils/request.dart';

///考试等级接口
class TestLevelApi {
  TestLevelApi._();

  static final _singleton = TestLevelApi._();

  factory TestLevelApi() => _singleton;

  ///查询
  Future<TestLevelQueryRes> query(final TestLevelQueryReq req) =>
      request
          .getHandler(path: '/${req.tenantId}/test-level', params: req.toMap())
          .then((res) => TestLevelQueryRes.fromModel(res));

  ///加载
  Future<TestLevelInfoRes> info(final String id) => request
      .getHandler(path: '/test-level/$id')
      .then((res) => TestLevelInfoRes.fromModel(res));

  ///新增
  Future<BaseModelRes> add(final TestLevelAddReq req) => request
      .postHandler(path: '/${req.tenantId}/test-level', data: req.toMap());

  ///修改
  Future<BaseModelRes> modify(final TestLevelModifyReq req) =>
      request.putHandler(path: '/test-level/${req.id}', data: req.toMap());

  ///删除
  Future<BaseModelRes> delete(final String id) =>
      request.deleteHandler(path: '/test-level/$id');
}

///考试等级接口单例
final testLevelApi = TestLevelApi();
